<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>确认订单页面</title>
		<link rel="stylesheet" type="text/css" href="../css/public.css" />
		<link rel="stylesheet" type="text/css" href="../css/proList.css" />
		<link rel="stylesheet" type="text/css" href="../css/mygxin.css" />
	</head>

	<body>
		
		<!------------------------------head------------------------------>
		<div class="head">
			<div class="wrapper clearfix">
				<div class="clearfix" id="top">
					<h1 class="fl">
					<a href="index.html"><img src="../img/logo.png" /></a>
				</h1>
					<div class="fr clearfix" id="top1">

						<p class="fl">
							<a href="user/mygxin.html" id="login">apple</a>
							<a href="userServlet?task=logout">退出</a>
						</p>

						<form action="" method="" class="fl">
							<input type="text" placeholder="热门搜索：干花花瓶" name="key" style="line-height: 30px" /> <input type="submit" style="margin-top: -30px;" value="" />
						</form>
						<div class="btn fl clearfix">
							<a href="user/mygxin.jsp"><img src="../img/grzx.png" /></a>
							<a href="#" class="er1"><img src="../img/ewm.png" /></a>
							<a href="user/cart.jsp"><img src="../img/gwc.png" /></a>
							<p>
								<a href="#"><img src="../img/smewm.png" /></a>
							</p>
						</div>
					</div>
				</div>
				<ul class="clearfix" id="bott">
					<li>
						<a href="index.jsp">首页</a>
					</li>
					<li>
						<a id="all" href="index.jsp" style="cursor: pointer">所有商品</a>
						<div class="sList"></div>
					</li>
					<li>
						<a id=6 style="cursor: pointer" href="mcServlet?task=typeMc&mcTypeId=6">装饰摆件</a>
						<div class="sList2" id="s6"></div>
					</li>
					<li>
						<a href="" style="cursor: pointer" id="7">布艺软饰</a>
						<div class="sList2"></div>
					</li>
					<li>
						<a href="">墙式壁挂</a>
					</li>
					<li>
						<a href="">蜡艺香薰</a>
					</li>
					<li>
						<a href="">创意家居</a>
					</li>
				</ul>
			</div>
		</div>
		
		<div class="order cart mt">
			<!-----------------orderCon------------------->
			<div class="orderCon wrapper clearfix">
				<div class="orderL fl">
					<!--------h3---------------->
					<h3>收件信息<a href="user/address.jsp" class="fr">新增地址</a></h3>
					<!--------addres---------------->
					<div class="addres clearfix">
						<div class="addre fl">
							<div class="tit clearfix">
								<p class="fl" id="userName">张三
								</p>
								<p class="fr">
									 <span>|</span>
									<a class="delete" id="">删除</a>
									<span>|</span>
									<a href="user/address.jsp">编辑</a> 
								</p>
							</div>
							<div class="addCon">
								<p class="address">福建省福州市</p>
								<p class="phone">12345678909</p>
							</div>
						</div>
					</div>
				
				</div>
				<div id="add">
				
				</div>
				<div class="orderR fr">
					<div class="msg">
						<h3>订单内容<a href="user/cart.jsp" class="fr">返回购物车</a></h3>
						<!--------ul---------------->
						<ul class="clearfix">
							<li class="fl">
								<img style="width: 100px;height: 100px;" src="../img/like02.jpg">
							</li>
							<li class="fl">
								<p>瓷器</p>
								<!-- <p>颜色分类：烟灰色玻璃瓶</p> -->
								<p>数量：1</p>
							</li>
							<li class="fr">￥59.9</li>
						</ul>
					</div>
					<!--------tips---------------->
					<div class="tips">
						<p><span class="fl">商品金额：</span><span class="fr">￥59.9</span></p>
						<p><span class="fl">优惠金额：</span><span class="fr">￥0.00</span></p>
						<p><span class="fl">运费：</span><span class="fr">免运费</span></p>
					</div>
					<!--------tips count---------------->
					<div class="count tips">
						<p><span class="fl">合计：</span><span class="fr">￥59.9</span></p>
					</div>
					<a class="pay" id="commit" style="cursor: pointer;">提交订单</a>
				</div>
			</div>
		</div>
	
	
		<script src="js/jquery-1.12.4.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/public.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/pro.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/user.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			$("#commit").click(function(){
					//判断是否有on样式，有的话则表示选中了地址，无的话，表示请选择地址
					var isHas = $(".addre").hasClass("on");
					var userName,address,phone;
					if(isHas){
						$(".on").addClass("unique");
						userName = $(".unique").children(".tit").children("#userName").text(); 
						address = $(".unique").children(".addCon").children(".address").text();
						phone = $(".unique").children(".addCon").children(".phone").text();
						console.log(userName)
						console.log(address)
						console.log(phone)
						$.ajax({
							type:"post",
							url:"orderServlet",
							data:{
								"task":"commitOrder",
								"userName":userName,
								"phone":phone,
								"address":address
							},
							success:function(msg){
								if(msg==2){
									alert("提交订单失败！")
								}else{
									var orderNum = msg
									window.location.href = "user/pay.jsp"
								}
							}
						});
						
					}else{
						alert("请选择收货地址！")
					}
				
			});
			
			//删除  使用ajax做的
			$(".delete").click(function() {
				var id = $(this).attr("id");
				//alert(id)
				$.ajax({
					type : "post",
					url : "addressServlet",
					data : {
						"id" : id,
						"task" : "delete",
					},
					success : function(message) {
						if (message == 1) {
							$("#"+id).parents(".addre").remove();
						} else {
							alert("删除失败！")
						}
					}
				});
			});
			
		</script>
	</body>

</html>